#!/usr/bin/perl
use utf8;
use strict;
use Data::Dumper;

$Data::Dumper::Useqq = 1;{
 no warnings 'redefine';
 sub Data::Dumper::qquote {
   my $s = shift;
   return "'$s'";
 }
}

open (FILE, "out.txt") or die "Sorry, but i can't open 'out.txt'";
binmode(FILE, ":encoding(utf-8)");
binmode(STDOUT, ":encoding(utf-8)");
binmode(STDERR, ":encoding(utf-8)");

my @s=<FILE>;
my %persn;
my $i;

foreach my $line (@s){
	if ($i = index($line, "FPerson") != -1)
	{
		$line  =~ s/"//g;
		$i = index ($line, "= ");
		$a = substr ($line, $i+2,length($line)-$i-3);
		#$a_cut = substr ($a, 0, length($a)-1);
		$persn{lc($a)} += 1;
		
	}
}
#my @sort = sort  %persn;
my $el;
my @sort;
@sort = sort keys %persn;
my $i;
my $n, my $d, my $a;
for ($i=0; $i<scalar(@sort) ; $i++){
#  if ($persn{$sort[$i]} ne 1){ 
  $n = substr($sort[$i], 0, length ($sort[$i])-1);
  $d = substr($sort[$i], 0, length ($sort[$i])-2);
 
#  if ($sort[$i-1] eq $n){splice(@sort, $i,1);}
#  elsif ($sort[$i-2] eq $d){splice (@sort, $i,1);}
    
#     print "\t$sort[$i]\n";}
#  else {
    print "$sort[$i]\t$persn{$sort[$i]}\n";
#}
#  }
}

#foreach $el (sort keys %persn){
#	print "$el\t$persn{$el}\n";
#}


#print Dumper(\%persn);

